package classloader;

import org.junit.Test;

import java.io.*;

/**
 * @ClassName Encryption
 * @Description TODO
 * 加密 encryption
 * 解密 decryption
 * @Author liang
 * @Date 2018\10\23 0023 10:28
 * @Version 1.0
 **/
public class Encryption {
    @Test
    public void test01(){
        int a = 3; // 0000 0011
        System.out.println(Integer.toBinaryString(a ^ 0xff));  //异或，取反。 11111100
    }
    //加密
    public static void encrpt(File src,File dest) throws IOException {
        FileInputStream fileInputStream = new FileInputStream(src);
        FileOutputStream fileOutputStream = new FileOutputStream(dest);
        //按字节读取
        int temp = -1;
        while ((temp = fileInputStream.read()) != -1){
            fileOutputStream.write(temp ^ 0xff); //取反操作
        }

    }
    //解密


    @Test
    public void test02() throws IOException {
        encrpt(new File("D:/Hi.class"),new File("D:/encryptionClass/Hi.class"));
    }
}
